#!/bin/sh

if [ -f /etc/profile ]; then
  source /etc/profile
fi

case "$1" in
  start)
    echo -n "Starting crond... "
    start-stop-daemon -S -q -m -b -p /var/run/crond.pid --exec /usr/sbin/crond -- -f
    [ $? -eq 0 ] && echo "OK" || echo "FAIL"
    ;;
  stop)
    echo -n "Stopping crond... "
    start-stop-daemon -K -q -p /var/run/crond.pid
    [ $? -eq 0 ] && echo "OK" || echo "FAIL"
    ;;
  restart)
    "$0" stop
    sleep 1
    "$0" start
    ;;
  *)
    echo "Usage: $0 {start|stop|restart}"
    ;;
esac
